import { request } from "@/request";
//新增家庭
export const addFamily = (params: API.addFamily) =>
  request({
    method: "POST",
    url: "/family/add",
    data: params,
  });
//修改家庭
export const updateFamily = (params: API.updateFamily) =>
  request({
    method: "PUT",
    url: "/family/update",
    data: params,
  });
//删除家庭
export const deleteFamily = (params: { id: string }) =>
  request({
    method: "DELETE",
    url: `/family/del/${params.id}`,
  });

//退出家庭
export const quitFamily = (id:string) =>request({
    method: 'DELETE',
    url:`/familyMember/del/${id}`
})

  //家庭列表
export const getFamilyList = (params:{name?:string}) =>request<any[]>({
    method:'POST',
    url:'/family/search',
    data:params||{},
})

//生成家庭邀请码
export const createFamilyCode = (id:string) =>request<string>({
    method:'GET',
    url:`/family/createCode/${id}`
})
//根据家庭码加入指定家庭
export const joinFamilyByCode = (code:string) =>request({
    method:'POST',
    url:`/family/join/${code}`
})